package cn.czh0123.config;

import cn.czh0123.interceptor.MinioImageInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    private final MinioImageInterceptor minioImageInterceptor;

    public WebConfig(MinioImageInterceptor minioImageInterceptor) {
        this.minioImageInterceptor = minioImageInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器并设置拦截的 URL
        registry.addInterceptor(minioImageInterceptor)
                .addPathPatterns(MinioImageInterceptor.PREVIEW_PATH_PREFIX + "/**");  // 配置拦截的路径
    }
}
